using Cysharp.Threading.Tasks;

namespace M13.Game.Entity.Player
{
    public class PlayerStateIdle : PlayerStateBase
    {
        public PlayerStateIdle(string stateName)
        {
            this.StateName = stateName;
        }
        public override void Enter()
        {
            animator.Play("1056_Idle", 0);
        }
        public override void Update()
        {
            if (inputCtrlSystem.AxisXInput != 0 || inputCtrlSystem.AxisYInput != 0)
            {
                stateMachine.SwitchState(typeof(PlayerStateMove));
                return;
            }
        }

        public override bool TryEnter()
        {
            if (inputCtrlSystem.AxisXInput == 0 && inputCtrlSystem.AxisYInput == 0)
                return true;
            return false;
        }
        public override bool TryExit()
        {
            return true;
        }
        
        public override UniTask GetAnimPlayTask()
        {
            AnimPlayTask = UniTask.WaitUntil(() => GetAnimPlayProgress() > 0.99f && IsCurrentAnimPlaying(GetAnimName()));
            return AnimPlayTask;
        }

        public override string GetAnimName()
        {
            return "1056_Idle";
        }
    }
}